

function foo(this: { name: string }, name: string, age: number) {
    console.log(this, foo);
}


// 1. ThisParameterType  获取函数的this类型
type FooThisType = ThisParameterType<typeof foo>


// 2. OmitThisParameter // 删除this类型 剩下函数类型
type PureFooType = OmitThisParameter<typeof foo>


// 3. ThisType :  绑定对象的上下文this
interface IState {
    name: string,
    age: number
}

interface IStore {
    state: IState;
    eat: () => void
    swim: () => void
}

const store: IStore & ThisType<IState> = {
    state: {
        "name": "刘曜宇",
        age: 25
    },
    eat: function () {
        console.log(this);// 绑定对象的上下文this
    },
    swim: function () {
        console.log(this);
    }
}

store.eat.call(store.state)

export { }